Using literal boolean values in assertions can lead to less readable and less informative unit tests. When a test fails, it’s important to have a
clear understanding of what the test was checking and why it failed. Most of the testing frameworks provide more explicit assertion methods that will
provide a more helpful error message if the test fails.
Exceptions
In the context of xUnit, Assert.True
and Assert.False
are not flagged by this rule. This is because
Assert.Fail
was only introduced in 2020 with version 2.4.2
. Prior to this, developers used Assert.True(false,
message)
and Assert.False(true, message)
as workarounds to simulate the functionality of Assert.Fail()
.